<?php

namespace IDock\Insurance\ACIC\Request;

use Exception;
use IDock\Insurance\ACIC\Response\RenewalInquiryResponse;
use IDock\Visitor\RenewalInquiryVisitor;

class RenewalInquiryRequest extends AllACICRequest
{
    protected $code = 'Q11';

    protected $response = RenewalInquiryResponse::class;

    protected $urlTip = '续保查询';

    /*** @var  RenewalInquiryVisitor $visitor */
    protected $visitor;

    /**
     * @return array
     * @throws Exception
     */
    public function generate(): array
    {
        $param = [
            'VIN' => $this->visitor->vin,
            'EngineNo' => $this->visitor->engineNo,
            'PlateNo' => $this->visitor->licenseNo,
            'Type' => $this->visitor->argc['type'] ?? '',
        ];
        if (!$param['PlateNo']) {
            $param['PlateNo'] = '*';
        }

        if ($param['Type'] === '') {
            unset($param['Type']);
        }
        return $param;
    }
}